Những câu hỏi liên quan
Xuân Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2022 lúc 22:18

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x>0) t+=x;

}

cout<<t;

return 0;

}

Bình luận (0)
Khánh Mỹ
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 1 2021 lúc 8:35

uses crt;

var a:array[1..100]of integer;

i,n,kt,dem,j:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

for i:=1 to n do 

  if a[i]>1 then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

  if a[i] mod j=0 then 

begin

kt:=1;

break;

end;

if kt=0 then inc(dem);

end;

writeln('So phan tu la so nguyen to la: ',dem);

readln;

end.

Bình luận (1)
Hương Lê
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:50

Bài 1

Var a:array:[1..99] of integer;

i,n:integer;

s:longint;

Begin

Repeat

Write('n = ');readln(n);

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

Write('Nhap diem thu ',i,' = ');readln(a[i]);

if a[i] mod 2 = 0 then s:=s+a[i];

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so chan la ',s);

Readln

End.

Bình luận (0)
Kiều Vũ Linh
10 tháng 5 2023 lúc 17:50

Bài 2

Var a:array:[1..99] of integer;

i,n:integer;

s:longint;

Begin

Repeat

Write('n = ');readln(n);

Until (n > 0) and (n < 100);

For i:=1 to n do

Begin

Write('Nhap diem thu ',i,' = ');readln(a[i]);

if a[i] mod 2 <> 0 then s:=s+a[i];

End;

Write('Cac so vua nhap la: ');

For i:=1 to n do 

Write(a[i]:8);

writeln;

write('Tong cac so le la ',s);

Readln

End.

Bình luận (0)
Quỳnh Anh Đào
Xem chi tiết
Xuân Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 3 2022 lúc 8:12

uses crt;

var a:array[1..100]of integer;

i,n,dem1,dem2:integer;

begin

clrscr;

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do write(a[i]:4);

writeln;

dem1:=0;

for i:=1 to n do 

  if (a[i]>a[i-1]) and (a[i]>a[i+1]) then dem1:=dem1+1;

dem2:=0;

for i:=1 to n do 

  if (a[i]<a[i-1]) and (a[i]<a[i+1]) then dem2:=dem2+1;

writeln(dem1);

writeln(dem2);

readln;

end.

Bình luận (0)
Nguyễn Thị Hiền
Xem chi tiết
Trương Nhật Huy
7 tháng 5 2021 lúc 20:26

Khi nãy gửi nhầm 2 cái nha 

program Baitap1;

uses crt;

var Min ,n, i:integer;

      A: array [1..1000] of integer;

begin

clrscr;

write('Nhap N ');readln(n);

for i:=1 to n do begin

   write('A[',i,']=');readln(A[i]);

                        end;

Min:=A[1];

for i:=1 to n do if Min>A[i] then Min:=A[i];

write('So Nho Nhat Trong Mang La ',Min);

readln;

end.       

Bình luận (0)
Trương Nhật Huy
7 tháng 5 2021 lúc 20:19

Bình luận (0)
Trương Nhật Huy
7 tháng 5 2021 lúc 20:20

Bình luận (0)
Võ Trần Nguyên
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 4 2021 lúc 20:44

uses crt;

var a:array[1..100]of integer;

i,n,t,dem:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then

begin

t:=t+a[i];

inc(dem);

end;

writeln('Tong cac so chan la: ',t);

writeln('So luong so chan la: ',dem);

readln;

end.

Bình luận (0)
Bich Ngoc
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:02

Bạn viết hết đề ra đi bạn 

Bình luận (0)
Quân Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 20:57

Câu 1: 

uses crt;

var a:array[1..500]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

       write('A[',i,']='); readln(a[i]);

  end;

t:=0;

for i:=1 to n do 

  if (a[i]<0) and (a[i] mod 7=0) then t:=t+a[i];

writeln('Tong cac so am chia het cho 7 la: ',t);

readln;

end.

Câu 2: 

uses crt;

var c,a:array[1..10]of integer;

i,kt,j,dem:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

write('C[',i,']='); readln(c[i]);

end;

dem:=0;

for i:=1 to 10 do 

  if c[i]>1 then 

begin

kt:=0;

for j:=2 to c[i]-1 do 

  if c[i] mod j=0 then kt:=1;

if kt=0 then 

begin

inc(dem);

a[dem]:=c[i];

end;

end;

if dem=0 then writeln('Trong day khong co so nguyen to')

else begin

writeln('Cac so nguyen to trong day la: ');

for i:=1 to dem do

write(a[i]:4);

end;

readln;

end.

Câu 3: 

uses crt;

var d:array[1..200]of integer;

i,k,dem:integer;

begin

clrscr;

write('Nhap k='); readln(k);

for i:=1 to k do 

  begin

write('D[',i,']='); readln(d[i]);

end;

dem:=0;

for i:=1 to k do 

  if (a[i] mod 2=0) and (a[i]>=10) then inc(dem);

writeln('So phan tu chan co 2 chu so la: ',dem);

readln;

end.

Bình luận (0)